//
//  FGChatConfiguration.m
//  FGChatKit
//
//  Created by Henry on 2021/5/10.
//

#import "FGChatConfiguration.h"
#import "UIColor+FGChat.h"

@implementation FGChatConfiguration

static FGChatConfiguration *configuration;

+ (instancetype)shareInstance {
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        configuration = [[FGChatConfiguration alloc] init];
    });
    return configuration;
}

- (instancetype)init
{
    self = [super init];
    if (self) {
        if (@available(iOS 13.0, *)) {
            self.backgroundColor = [UIColor groupTableViewBackgroundColor];
        } else {
            self.backgroundColor = [UIColor groupTableViewBackgroundColor];
        }
        self.languageType = [[[NSUserDefaults standardUserDefaults] valueForKey:HCLanguageTypeKey] integerValue];
        _maxImageLength = 8;
        _maxImageWidth = 2000;
        
        _defaultAvatarCorner = 5;
        _defaultFont = [UIFont systemFontOfSize:17];
        _lineColor = [UIColor fg_colorWithLightColor:[UIColor fg_colorWithString:@"#DDDDDD"] darkColor:[UIColor fg_colorWithString:@"#333333"]];

    }
    return self;
}

- (void)setLanguageType:(HCLanguageType)languageType {
    if (_languageType == languageType) {
        return;
    }
    _languageType = languageType;
    [[NSUserDefaults standardUserDefaults] setValue:@(languageType) forKey:HCLanguageTypeKey];
    [[NSUserDefaults standardUserDefaults] synchronize];
    [NSBundle hc_resetLanguage];
}

+ (BOOL)isSelf:(NSString *)userId {
    return [FGChatConfiguration.shareInstance.loginId isEqualToString:userId];
}

@end
